<template>
  <div class="login">
    <div class="block">
      <el-input v-model="username" placeholder="请输入内容"></el-input>
      <el-input v-model="password" placeholder="请输入内容"></el-input>
      <el-button type="primary" @click="login">登录</el-button>
    </div>
  </div>
</template>
<script>
import { loginApi} from '../api/admin'
export default {
  data() {
    return {
      username: "",
      password: "",
    }
  },
  methods:{
   async login(){
        let data={ username:this.username,password:this.password }
        let res=await loginApi(data)
        if(res.code==200){
            localStorage.setItem('admin',JSON.stringify(res.list))
            this.$router.replace('/')
        }else{
            alert(res.msg)
        }
    },
  }
};
</script>
<style lang="less" scoped>
.login{
    width: 100vw;
    height: 100vh;
    .block{
        position: absolute;
        padding: 0 30px;
        border-radius: 5px;
        display: flex;
        background: #ccc;
        flex-direction: column;
        justify-content: space-evenly;
        align-items: center;
        left: 50%;
        top: 50%;
        width: 30%;
        height: 50%;
        transform: translate(-50%,-50%);
    }
}
</style>
